.class public abstract Lcom/android/inputmethod/latin/VoiceKeyboardManager;
.super Ljava/lang/Object;
.source "VoiceKeyboardManager.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;
    }
.end annotation


# static fields
.field static final ANALYZING:I = 0x3

.field static final DEBUG:Z = false

.field private static final DEFAULT_LOCALE:Ljava/lang/String; = "en_US"

.field static final ERROR:I = 0x4

.field static final GOOGLE:I = 0x1

.field static final IDLE:I = 0x0

.field private static final IME_OPTION_NO_MICROPHONE:Ljava/lang/String; = "nm"

.field static final INITIALIZING:I = 0x1

.field static final LISTENING:I = 0x2

.field static final SYSTEM_SETTINGS_KEY:Ljava/lang/String; = "voice_to_text"

.field static final TAG:Ljava/lang/String; = "###### VoiceKeyboardManager ######"

.field static final VLINGO:I


# instance fields
.field protected mContext:Lcom/android/inputmethod/latin/LatinIME;

.field protected mCurrentStatus:I

.field private mEngineId:I

.field protected mErrorNo:I

.field protected mHandler:Landroid/os/Handler;

.field protected mHideErrorMessageRunnable:Ljava/lang/Runnable;

.field protected mIsErrorMessageShown:Z

.field protected mIsVoiceKeyboardShown:Z

.field private mLocale:Ljava/lang/String;

.field protected mSpeechEnded:Z

.field protected mVIListener:Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;

.field protected mVoiceKeyboardView:Landroid/view/View;

.field private mWindow:Landroid/widget/PopupWindow;


# direct methods
.method protected constructor <init>(Lcom/android/inputmethod/latin/LatinIME;Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;I)V
    .locals 4
    .parameter "context"
    .parameter "listener"
    .parameter "engineId"

    .prologue
    const/4 v3, 0x0

    const/4 v2, 0x0

    .line 115
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 62
    const/4 v0, -0x1

    iput v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mEngineId:I

    .line 63
    new-instance v0, Landroid/os/Handler;

    invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

    move-result-object v1

    invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mHandler:Landroid/os/Handler;

    .line 64
    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsErrorMessageShown:Z

    .line 65
    new-instance v0, Lcom/android/inputmethod/latin/VoiceKeyboardManager$1;

    invoke-direct {v0, p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager$1;-><init>(Lcom/android/inputmethod/latin/VoiceKeyboardManager;)V

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mHideErrorMessageRunnable:Ljava/lang/Runnable;

    .line 75
    iput-object v3, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVIListener:Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;

    .line 76
    iput-object v3, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    .line 78
    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    .line 80
    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mSpeechEnded:Z

    .line 89
    iput v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mCurrentStatus:I

    .line 91
    iput v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mErrorNo:I

    .line 95
    iput-object v3, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mLocale:Ljava/lang/String;

    .line 116
    iput-object p1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    .line 117
    iput-object p2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVIListener:Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;

    .line 118
    iput p3, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mEngineId:I

    .line 120
    invoke-virtual {p0, p1}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->initPopupWindow(Landroid/content/Context;)V

    .line 121
    return-void
.end method

.method public static getInstanceByEngineId(Lcom/android/inputmethod/latin/LatinIME;Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;I)Lcom/android/inputmethod/latin/VoiceKeyboardManager;
    .locals 1
    .parameter "context"
    .parameter "listener"
    .parameter "engineId"

    .prologue
    .line 101
    if-nez p2, :cond_0

    .line 102
    invoke-static {p0, p1}, Lcom/android/inputmethod/latin/VlingoVoiceManager;->getInstance(Lcom/android/inputmethod/latin/LatinIME;Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;)Lcom/android/inputmethod/latin/VlingoVoiceManager;

    move-result-object v0

    .line 104
    :goto_0
    return-object v0

    :cond_0
    invoke-static {p0, p1}, Lcom/android/inputmethod/latin/GoogleVoiceManager;->getInstance(Lcom/android/inputmethod/latin/LatinIME;Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;)Lcom/android/inputmethod/latin/GoogleVoiceManager;

    move-result-object v0

    goto :goto_0
.end method


# virtual methods
.method protected abstract createVoiceKeyboardView()Landroid/view/View;
.end method

.method public eligibleForVoiceRecognition(Lcom/android/inputmethod/latin/FieldContext;Landroid/view/inputmethod/EditorInfo;)Z
    .locals 2
    .parameter "fieldContext"
    .parameter "attribute"

    .prologue
    .line 109
    if-eqz p2, :cond_0

    iget-object v0, p2, Landroid/view/inputmethod/EditorInfo;->privateImeOptions:Ljava/lang/String;

    if-eqz v0, :cond_0

    iget-object v0, p2, Landroid/view/inputmethod/EditorInfo;->privateImeOptions:Ljava/lang/String;

    const-string v1, "nm"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-nez v0, :cond_1

    :cond_0
    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_1
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public getEngineId()I
    .locals 1

    .prologue
    .line 132
    iget v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mEngineId:I

    return v0
.end method

.method protected abstract getErrorStringId(I)I
.end method

.method protected getExpectedHeight()I
    .locals 3

    .prologue
    .line 258
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {v1}, Lcom/android/inputmethod/latin/LatinIME;->getWindow()Landroid/app/Dialog;

    move-result-object v1

    const v2, 0x102001e

    invoke-virtual {v1, v2}, Landroid/app/Dialog;->findViewById(I)Landroid/view/View;

    move-result-object v1

    check-cast v1, Landroid/widget/FrameLayout;

    const/4 v2, 0x0

    invoke-virtual {v1, v2}, Landroid/widget/FrameLayout;->getChildAt(I)Landroid/view/View;

    move-result-object v0

    .line 259
    .local v0, keyboardView:Landroid/view/View;
    if-eqz v0, :cond_0

    invoke-virtual {v0}, Landroid/view/View;->getVisibility()I

    move-result v1

    if-nez v1, :cond_0

    invoke-virtual {v0}, Landroid/view/View;->getHeight()I

    move-result v1

    if-lez v1, :cond_0

    .line 261
    invoke-virtual {v0}, Landroid/view/View;->getHeight()I

    move-result v1

    .line 263
    :goto_0
    return v1

    :cond_0
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {v1}, Lcom/android/inputmethod/latin/LatinIME;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    const v2, 0x7f090004

    invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

    move-result v1

    goto :goto_0
.end method

.method public getLocale()Ljava/lang/String;
    .locals 1

    .prologue
    .line 145
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mLocale:Ljava/lang/String;

    return-object v0
.end method

.method protected declared-synchronized hideVoiceKeyboard()V
    .locals 1

    .prologue
    .line 247
    monitor-enter p0

    :try_start_0
    iget-boolean v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    invoke-virtual {v0}, Landroid/widget/PopupWindow;->isShowing()Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    if-eqz v0, :cond_0

    .line 249
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    invoke-virtual {v0}, Landroid/widget/PopupWindow;->dismiss()V

    .line 250
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 252
    :cond_0
    monitor-exit p0

    return-void

    .line 247
    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method protected initPopupWindow(Landroid/content/Context;)V
    .locals 3
    .parameter "context"

    .prologue
    .line 124
    new-instance v0, Landroid/widget/PopupWindow;

    invoke-direct {v0, p1}, Landroid/widget/PopupWindow;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    .line 125
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    const/4 v1, -0x1

    const/4 v2, -0x2

    invoke-virtual {v0, v1, v2}, Landroid/widget/PopupWindow;->setWindowLayoutMode(II)V

    .line 126
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/widget/PopupWindow;->setClippingEnabled(Z)V

    .line 127
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/widget/PopupWindow;->setBackgroundDrawable(Landroid/graphics/drawable/Drawable;)V

    .line 128
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    const/4 v1, 0x2

    invoke-virtual {v0, v1}, Landroid/widget/PopupWindow;->setInputMethodMode(I)V

    .line 129
    return-void
.end method

.method public isActive()Z
    .locals 1

    .prologue
    .line 162
    iget v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mCurrentStatus:I

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public abstract isRecognitionAvailable(Landroid/content/Context;)Z
.end method

.method public isVoiceKeyboardShown()Z
    .locals 1

    .prologue
    .line 150
    iget-boolean v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    return v0
.end method

.method public onCancel()V
    .locals 1

    .prologue
    .line 170
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->hideVoiceKeyboard()V

    .line 172
    const/4 v0, 0x0

    iput v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mCurrentStatus:I

    .line 174
    return-void
.end method

.method public onError(I)V
    .locals 2
    .parameter "error"

    .prologue
    .line 181
    iget-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {p0, p1}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->getErrorStringId(I)I

    move-result v1

    invoke-virtual {v0, v1}, Lcom/android/inputmethod/latin/LatinIME;->getString(I)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, v0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->showErrorMessage(Ljava/lang/String;)V

    .line 184
    const/4 v0, 0x4

    iput v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mCurrentStatus:I

    .line 185
    iput p1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mErrorNo:I

    .line 187
    return-void
.end method

.method public onFinish()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 201
    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    .line 202
    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 203
    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVIListener:Lcom/android/inputmethod/latin/VoiceKeyboardManager$VoiceInputListener;

    .line 205
    const/4 v0, 0x0

    iput v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mCurrentStatus:I

    .line 207
    return-void
.end method

.method public onOrientationChanged()V
    .locals 1

    .prologue
    .line 155
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->hideVoiceKeyboard()V

    .line 157
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 158
    return-void
.end method

.method protected onResume()V
    .locals 0

    .prologue
    .line 215
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->showVoiceKeyboard()V

    .line 216
    return-void
.end method

.method protected abstract showErrorMessage(Ljava/lang/String;)V
.end method

.method protected declared-synchronized showVoiceKeyboard()V
    .locals 6

    .prologue
    .line 224
    monitor-enter p0

    :try_start_0
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    if-nez v2, :cond_0

    .line 225
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->createVoiceKeyboardView()Landroid/view/View;

    move-result-object v2

    iput-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 228
    :cond_0
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 230
    .local v1, voiceView:Landroid/view/View;
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    if-eqz v2, :cond_1

    iget-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    if-nez v2, :cond_1

    if-eqz v1, :cond_1

    .line 231
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {v2}, Lcom/android/inputmethod/latin/LatinIME;->getWindow()Landroid/app/Dialog;

    move-result-object v2

    const v3, 0x102001e

    invoke-virtual {v2, v3}, Landroid/app/Dialog;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/FrameLayout;

    .line 233
    .local v0, anchorView:Landroid/widget/FrameLayout;
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    invoke-virtual {v2, v1}, Landroid/widget/PopupWindow;->setContentView(Landroid/view/View;)V

    .line 234
    const/4 v2, 0x0

    const/4 v3, 0x0

    invoke-static {v2, v3}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I

    move-result v2

    const/4 v3, 0x0

    const/4 v4, 0x0

    invoke-static {v3, v4}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I

    move-result v3

    invoke-virtual {v1, v2, v3}, Landroid/view/View;->measure(II)V

    .line 236
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    invoke-virtual {v1}, Landroid/view/View;->getMeasuredHeight()I

    move-result v3

    invoke-virtual {v2, v3}, Landroid/widget/PopupWindow;->setHeight(I)V

    .line 237
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    iget-object v3, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {v3}, Lcom/android/inputmethod/latin/LatinIME;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    invoke-virtual {v3}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;

    move-result-object v3

    iget v3, v3, Landroid/util/DisplayMetrics;->widthPixels:I

    invoke-virtual {v2, v3}, Landroid/widget/PopupWindow;->setWidth(I)V

    .line 238
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mWindow:Landroid/widget/PopupWindow;

    const/16 v3, 0x50

    const/4 v4, 0x0

    const/4 v5, 0x0

    invoke-virtual {v2, v0, v3, v4, v5}, Landroid/widget/PopupWindow;->showAtLocation(Landroid/view/View;III)V

    .line 239
    const/4 v2, 0x1

    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 241
    .end local v0           #anchorView:Landroid/widget/FrameLayout;
    :cond_1
    monitor-exit p0

    return-void

    .line 224
    .end local v1           #voiceView:Landroid/view/View;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method public abstract startRecognition(Lcom/android/inputmethod/latin/FieldContext;)V
.end method

.method public updateLocale(Ljava/lang/String;)V
    .locals 1
    .parameter "locale"

    .prologue
    .line 137
    if-eqz p1, :cond_0

    .line 138
    iput-object p1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mLocale:Ljava/lang/String;

    .line 142
    :goto_0
    return-void

    .line 140
    :cond_0
    const-string v0, "en_US"

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mLocale:Ljava/lang/String;

    goto :goto_0
.end method
